import 'package:flutter/material.dart';
import 'package:suxuanapp/web/js_bridge.dart';
//https://www.jianshu.com/p/580757a03cfe
/**
 * //方式一
    print(js.context['location']['href']);
    //方式二
    print(window.location.href);
    var uri = Uri.dataFromString(window.location.href);
    var qp = uri.queryParameters;
    //获取参娄数ID，或你要找的参数
    var id = qp['ID'];
    print(id.replaceAll('#/', ''));
    作者：Dev_MrZhao
    链接：https://www.jianshu.com/p/580757a03cfe
    来源：简书
    著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。
 */
class WebArgsPage extends StatefulWidget {
  WebArgsPage({Key key,     @required this.title,
    @required this.msg,
    @required this.ID,
  }) : super(key: key);
  final String title;
  final String msg;
  final String ID;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}


class _MyHomePageState extends State<WebArgsPage>    {
  @override
  void initState() {
    super.initState();
     var url= JSBridge.getProperty(propertyName:'href',objName:'location');
     print(url);
     var uri = Uri.dataFromString(url);
    var qp = uri.queryParameters;
  //获取参娄数ID，或你要找的参数
    var id = qp['ID'];
    print(id);
  }
  @override
  Widget build(BuildContext context) {
//    js.context["locationSuccess"]=locationSuccess;
    return Scaffold(
      appBar: AppBar(
        title: Text("744"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            RaisedButton(child:         Text(
              'JS 案例',
            ),onPressed: (){
            },)
          ],
        ),
      ),
    );
  }

}
